<?php

namespace App\Admin\Extensions;

use Encore\Admin\Admin;

class PayAndRepayStatistic
{
    public function __construct($channels =  '', $date = '')
    {
        $this->channels = $channels;
        $this->date = $date;
    }

    protected function script()
    {
        return <<<SCRIPT

layui.use('layer', function(){
        var layer = layui.layer;
        $('.watch').click(function () {
           var that = this;
           var channels = $(that).attr('data-channels');
           var date = $(that).attr('data-date');
           layer.open({
              type: 2, 
              content: '/html/statistics.html?channels='+channels+'&date='+date,
              area: ['100%','100%'],
           }); 
       });
});

SCRIPT;
    }

    protected function render()
    {
        Admin::script($this->script());
        return "<a href='javascript:void(0)' class='watch' data-channels='{$this->channels}' data-date='{$this->date}'><img style='width: 23px; height: 23px;' src='/images/eye.png' alt='查看祥情'></a>";
    }

    public function __toString()
    {
        return $this->render();
    }
}